﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TuxedoLib;

namespace SpaceSquirrel.SpecialLevelStuff
{
	public class BirdFeeder : SpecialLevel
	{
		private int counter = 0;
		public int seedsLeft;
		private bool closingShown;

		public BirdFeeder(PlayScene scene)
			: base(scene)
		{
			this.HasPostInit = true;
			this.HasUpdate = true;
			this.counter = 0;
			int[][] seeds = new int[][] {
				new int[] { 4, 36 },
				new int[] { 11, 30 },
				new int[] { 4, 24 },
				new int[] { 11, 18 },
				new int[] { 4, 12 },
				new int[] { 11, 6 }
			};

			this.seedsLeft = seeds.Length;
			foreach (int[] seed in seeds)
			{
				scene.Sprites.Add(new Sprite("seeds", seed[0] * 16 + 8, seed[1] * 16 + 7));
			}

			Sprite bike = new Sprite("rocketbike", 12 * 16 + 8, 39 * 16 + 8);
			bike.floats = true;
			scene.Sprites.Add(bike);
			this.closingShown = false;
		}

		public override void Update()
		{
			Sprite p = this.scene.Player;
			this.counter++;
			if (this.counter == 3)
			{
				this.scene.Next = new DialogScene(this.scene, "Feeder1", false, false, false);
			}

			if (this.seedsLeft == 0 && !this.closingShown)
			{
				this.scene.Next = new DialogScene(this.scene, "Feeder2", false, false, false);
				this.scene.Sprites.Add(new Sprite("bird1", 8, 8));
				this.closingShown = true;
			}
		}
	}
}
